package composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : DuJiabao
 * @Date : 2021/3/3 18:42
 * @Project : design-pattern
 * @File : null.java
 * @Desc :
 */
public class College extends OrganizationComponent {
  List<OrganizationComponent> departments = new ArrayList<>();

  public College() {
  }

  public College(String name, String desc) {
    super(name, desc);
  }

  @Override
  public void add(OrganizationComponent department) {
    departments.add(department);
  }

  @Override
  public void remove(OrganizationComponent department) {
    departments.remove(department);
  }

  @Override
  public void print() {
    System.out.println(super.getName() + " " + super.getDesc());
    for (OrganizationComponent department : departments) {
      department.print();
    }
  }
}
